package com.salim.leetcode.$104;

import com.salim.leetcode.util.TreeNode;

public class MaximumDepthofBinaryTree {
    public int maxDepth(TreeNode root) {
        return loop(root,0);
    }

    public int loop(TreeNode current,int result){
        if(current==null){
            return result;
        }
        if(current.left==null && current.right==null){
            return result+1;
        }

        return Math.max(loop(current.left,result+1),loop(current.right,result+1));
    }
}
